package top.jiangqiang.qyblog.common.markdown.link;

final class Utilities {
    private Utilities() {
    }

    static String resolveAudioType(String source) {
        int period = source.lastIndexOf(".");
        if (period == -1) return null;

        String extension = source.substring(period + 1);
        return switch (extension) {
            case "opus" -> "audio/ogg; codecs=opus";
            case "weba" -> "audio/webm";
            case "webm" -> "audio/webm; codecs=opus";
            case "ogg" -> "audio/ogg";
            case "mp3" -> "audio/mpeg";
            case "wav" -> "audio/wav";
            case "flac" -> "audio/flac";
            default -> null;
        };
    }

    static String resolveVideoType(String source) {
        int period = source.lastIndexOf(".");
        if (period == -1) return null;

        String extension = source.substring(period + 1);
        return switch (extension) {
            case "mp4" -> "video/mp4";
            case "webm" -> "video/webm";
            case "ogv" -> "video/ogg";
            case "3gp" -> "video/3gp";
            default -> null;
        };
    }
}
